package com.xyy.saas.payment.cores.enums;


/**
 * @author wangtianqi
 * @date 2019/12/19 17:49
 */
public enum BusinessOrderTypeEnum {
    /**
     * 一块钱医生业务类型
     */
    YIKUAIQIAN_DOC("yikuaiqian_doc"),
    /**
     * 一块钱富民
     */
    YIKUAIQIAN_FM("yikuaiqian_fm"),
    /**
     * 一块钱药店业务类型
     */
    YIKUAIQIAN_DRUGSTORE("yikuaiqian_drugstore"),
    /**
     * ec_ka
     */
    EC_KA("ec_ka"),
    /**
     * ec_order
     */
    EC_ORDER("ec_order"),
    /**
     * 毛竹
     */
    SAAS_CRM("saas_crm"),
    SAAS_CRM_YBM("saas_crm_ybm"),
    SAAS_WEB("saas_web"),

    /**
     * 单品交易
     */
    SAAS_TRADE("saas_trade"),

    /**
     * 宜块钱资质认证业务
     */
    YIKUAIQIAN_ATTESTATION("yikuaiqian_attestation"),
    /**
     * 宜块钱保险业务
     */
    YIKUAIQIAN_INSURANCE("yikuaiqian_insurance"),
    /**
     * 宜块钱保险业务
     */
    YIKUAIQIAN_LINGZHI("yikuaiqian_lingzhi"),
    /**
     * 智慧脸商城
     */
    SAAS_MALL("saas_mall"),
    /**
     * 药帮忙POP
     */
    EC_POP("ec_pop"),
    /**
     * EC兼容买家业务
     */
    EC("ec");

    public static String getBusinessType(BusinessOrderTypeEnum businessOrderType) {
        switch(businessOrderType) {
            case EC_POP:
                return BusinessTypeEnum.EC.getType();
        }

        throw new UnsupportedOperationException("UnsupportedOperationException#getBusinessType, businessOrderType=" + businessOrderType);
    }

    public static String getBusinessType(String businessOrderType) {
        if(EC_POP.getType().equals(businessOrderType)) {
            return BusinessTypeEnum.EC.getType();
        }

        throw new UnsupportedOperationException("UnsupportedOperationException#getBusinessType, businessOrderType=" + businessOrderType);
    }

    private String type;

    BusinessOrderTypeEnum(String type){
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public static boolean contains(String type) {
        try {
           return BusinessOrderTypeEnum.valueOf(type.toUpperCase()).type.equals(type);
        } catch (Exception e) {
        }
        return false;
    }
}
